Shader "BP/Role_Alpha/Slash" {
    Properties {
        [HDR]_MainColor("Slash Color", Color) = (0, 0, 1, 1)
        _MainTex("Slash Tex", 2D) = "white"{}
        _NoiseTex ("Noise Tex", 2D) = "white"{}
        _SlashWidth("Slash Width", Range(0.01, 5)) = 1
        _GlowAmount("Glow Amount", Range(1, 10)) = 1
        _DissolveAmount("Dissolve Amount", Range(0.01, 10)) = 1
        _NoiseXSpeed("Noise XSpeed", Range(-20, 20)) = 0
        _NoiseYSpeed("Noise YSpeed", Range(-20, 20)) = 5

    }
    SubShader{
        Tags { "Queue" = "Transparent"}
        Blend SrcAlpha OneMinusSrcAlpha
        cull Off
        ZWrite Off

        Pass{
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            fixed4 _MainColor;
            sampler2D _MainTex;
            sampler2D _NoiseTex;
            float4 _NoiseTex_ST;
            half _SlashWidth;
            half _GlowAmount;
            half _DissolveAmount;
            half _NoiseXSpeed;
            half _NoiseYSpeed;

            struct a2v {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f {
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
                float2 noiseUv : TEXCOORD1;
            };

            v2f vert(a2v v) {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                o.noiseUv = TRANSFORM_TEX(v.uv, _NoiseTex);
                return o;
            }

            
            fixed4 frag(v2f i) : SV_Target{
                i.noiseUv.x = (i.noiseUv.x + _Time * _NoiseXSpeed) % 1;
                i.noiseUv.y = (i.noiseUv.y + _Time * _NoiseYSpeed) % 1;

                fixed4 slashCol = tex2D(_MainTex, i.uv);
                fixed4 noiseCol = tex2D(_NoiseTex, i.noiseUv);
                
                slashCol = pow(slashCol.a, 1.0 / _SlashWidth);
                slashCol *= _GlowAmount;
                
                noiseCol = pow(noiseCol, _DissolveAmount);

                fixed4 col = slashCol * noiseCol;
                col.a = col.r;
                col.rgb *= _MainColor.rgb;
                return col;
            }
            

            /*
            fixed4 frag(v2f i) : SV_Target{
                i.noiseUv.x = (i.noiseUv.x + _Time * _NoiseXSpeed) % 1;
                i.noiseUv.y = (i.noiseUv.y + _Time * _NoiseYSpeed) % 1;

                fixed4 slashCol = tex2D(_MainTex, i.uv);
                fixed4 noiseCol = tex2D(_NoiseTex, i.noiseUv);
                
                slashCol.a = pow(slashCol.a, 1.0 / _SlashWidth);
                noiseCol.rgb = pow(noiseCol.rgb, _DissolveAmount);

                fixed4 col = slashCol * noiseCol;
                col.a = col.a * col.r;
                col = col.a * _MainColor;

               
                return col;
            }
            */

            /*
            fixed4 frag(v2f i) : SV_Target{
                i.noiseUv.x = (i.noiseUv.x + _Time * _NoiseXSpeed) % 1;

                fixed4 slashCol = tex2D(_MainTex, i.uv);
                
                slashCol.a = pow(slashCol.a, 1.0 / _SlashWidth);

                fixed4 col = slashCol;

                col = col * col.a * _MainColor;

               
                return col;
            }
            */

            /*
            fixed4 frag(v2f i) : SV_Target{
                i.noiseUv.x = (i.noiseUv.x + _Time * _NoiseXSpeed) % 1;

                fixed4 slashCol = tex2D(_MainTex, i.uv);
                slashCol.a = pow(slashCol.a, 1.0 / _SlashWidth);

                fixed4 col;
                col.r = slashCol.a;
                col.g = slashCol.a;
                col.b = slashCol.a;
                col.a = slashCol.a;

                col = col * col.a * _MainColor;

                return col;
            }
            */

            ENDCG   
        }
    }
}